﻿using System;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using Timer = System.Threading.Timer;

namespace BlueMarineWindowsFormsClient
{
    public class Status
    {
        private readonly ToolStripStatusLabel lblStatus;
       // private Timer time;

        public Status(ToolStripStatusLabel stt)
        {
            lblStatus = stt;
            lblStatus.Click += lblStatus_Click;
        }

        //private void refreshStt()
        //{
        //    if (time != null)
        //    {
        //        time.Dispose();
        //    }
        //    var handler = new TimerCallback(clearStt);
        //    time = new Timer(handler, null, 4000, -1);
        //}

        //private void clearStt(object sender)
        //{
        //    lblStatus.Text = "";
        //    time.Dispose();
        //}

        private void lblStatus_Click(object sender, EventArgs e)
        {
            if (lblStatus.Text != "")
            {
                MessageBox.Show(lblStatus.Text, "Status content", MessageBoxButtons.OK);
            }
        }

        public void ERROR(string error)
        {
            lblStatus.ForeColor = Color.Red;
            lblStatus.Text = "ERROR: " + error;
           // refreshStt();
        }

        public void SUCCESS(string success)
        {
            lblStatus.ForeColor = Color.SteelBlue;
            lblStatus.Text = "SUCCESS: " + success;
           // refreshStt();
        }

        public void FAIL(string fail)
        {
            lblStatus.ForeColor = Color.OrangeRed;
            lblStatus.Text = "FAIL: " + fail;
           // refreshStt();
        }

        public void STATUS(string status)
        {
            lblStatus.ForeColor = Color.Black;
            lblStatus.Text = status;
          //  refreshStt();
        }
    }
}